from pynput.keyboard import Controller,Key
from pynput import keyboard
import time

key = Controller()#初始化键盘事件
def 按下并松开键盘按键(按键):
    key.press(key=按键)
    time.sleep(0.1)
    key.release(key=按键)
class 多媒体按键:
    def 暂停():
        按下并松开键盘按键(Key.enter)
    def 下一曲():
        按下并松开键盘按键(Key.media_next)
    def 上一曲():
        按下并松开键盘按键(Key.media_previous)
    def 音量加():
        按下并松开键盘按键(Key.media_volume_up)
    def 音量减():
        按下并松开键盘按键(Key.media_volume_down)
    def 静音():
        按下并松开键盘按键(Key.media_volume_mute)
class QQ音乐按键:
    def 暂停():
        key.press(key=Key.ctrl)
        key.press(key=Key.alt)
        key.press(key=Key.f5)
        time.sleep(0.5)
        key.release(key=Key.ctrl)
        key.release(key=Key.alt)
        key.release(key=Key.f5)
    def 下一曲():
        key.press(key=Key.ctrl)
        key.press(key=Key.alt)
        key.press(key=Key.right)
        time.sleep(0.5)
        key.release(key=Key.ctrl)
        key.release(key=Key.alt)
        key.release(key=Key.right)
    def 上一曲():
        key.press(key=Key.ctrl)
        key.press(key=Key.alt)
        key.press(key=Key.left)
        time.sleep(0.5)
        key.release(key=Key.ctrl)
        key.release(key=Key.alt)
        key.release(key=Key.left)
    def 音量加():
        key.press(key=Key.ctrl)
        key.press(key=Key.alt)
        key.press(key=Key.up)
        time.sleep(0.1)
        key.release(key=Key.ctrl)
        key.release(key=Key.alt)
        key.release(key=Key.up)
    def 音量减():
        key.press(key=Key.ctrl)
        key.press(key=Key.alt)
        key.press(key=Key.down)
        time.sleep(0.1)
        key.release(key=Key.ctrl)
        key.release(key=Key.alt)
        key.release(key=Key.down)
class wps_ppt按键:
    def 向上翻页():
        按下并松开键盘按键(Key.up)
    def 向下翻页():
        按下并松开键盘按键(Key.down)
    def 从头开始放映():
        按下并松开键盘按键(Key.f5)
    def 开始放映():
        key.press(key=Key.shift)
        key.press(key=Key.f5)
        time.sleep(0.1)
        key.release(key=Key.shift)
        key.release(key=Key.f5)
    def 退出放映():
        按下并松开键盘按键(Key.esc)
if __name__ == '__main__' :
    QQ音乐按键.暂停()